package com.smsc.headend.task.engine.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.smsc.headend.module.fwu.entity.DeviceFirmwareVersion;
import com.smsc.headend.task.engine.mapper.DeviceFirmwareVersionMapper;
import com.smsc.headend.task.engine.service.DeviceFirmwareVersionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author qinbin
 * @date 2021/4/28
 * @vison v1.0
 */

@Service
public class DeviceFirmwareVersionServiceImpl extends ServiceImpl<DeviceFirmwareVersionMapper, DeviceFirmwareVersion> implements DeviceFirmwareVersionService {

    @Autowired
    private DeviceFirmwareVersionMapper deviceFirmwareVersionMapper;

    @Override
    public void saveFirmwareVersion(DeviceFirmwareVersion deviceFirmwareVersion) {

        QueryWrapper<DeviceFirmwareVersion> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("DEVICE_ID", deviceFirmwareVersion.getDeviceId())
                .eq("DEVICE_TYPE", deviceFirmwareVersion.getDeviceType())
                .eq("FW_TYPE", deviceFirmwareVersion.getFwType());
        deviceFirmwareVersionMapper.delete(queryWrapper);
        deviceFirmwareVersionMapper.insert(deviceFirmwareVersion);
    }
}
